config: allow minimum PD len up to 64
authorDavid Härdeman <[email protected]>
Sun, 14 Dec 2025 12:04:56 +0000 (13:04 +0100)
committerÁlvaro Fernández Rojas <[email protected]>
Sun, 14 Dec 2025 19:34:45 +0000 (20:34 +0100)
The current limit of [1,62] doesn't really seem to be justified. With
things like RFC9762 (DHCPv6-PD preferred), it isn't unlikely that we'll
see more DHCPv6-PD requests in the future, and not just from actual
routers.

The smallest realistic PD that can be allocated is a /64, so make that
the minimum.

Also, fix a bug in the logic (note that the PD_MIN_LEN_MAX actually
isn't enforced).

Closes: #352
Signed-off-by: David Härdeman <[email protected]>
Link: https://github.com/openwrt/odhcpd/pull/357
Signed-off-by: Álvaro Fernández Rojas <[email protected]>
README.md
src/config.c

index 869d2753dacf5f9a33b2cfc243c6869b47d3e466..97717d27b3a953cb2057b53fc0676bb1070dcdd5 100644 (file)
--- a/README.md
+++ b/README.md
@@ -89,7 +89,7 @@ and may also receive information from ubus
 | dhcpv6_na            |bool   | 1     | DHCPv6 stateful addressing hands out IA_NA - Internet Address - Network Address |
 | dhcpv6_pd            |bool   | 1     | DHCPv6 stateful addressing hands out IA_PD - Internet Address - Prefix Delegation (PD) |
 | dhcpv6_pd_preferred   |bool | 0 | Set the DHCPv6-PD Preferred (P) flag in outgoing ICMPv6 RA message PIOs (RFC9762); requires `dhcpv6` and `dhcpv6_pd`. |
-| dhcpv6_pd_min_len    |integer| -     | Minimum prefix length to delegate with IA_PD (value is adjusted if needed to be greater than the interface prefix length).  Range [1,62] |
+| dhcpv6_pd_min_len    |integer| -     | Minimum prefix length to delegate with IA_PD (value is adjusted if needed to be greater than the interface prefix length).  Range [1,64] |
 | router               |list   |`<local address>`| IPv4 addresses of routers on a given subnet (provided via DHCPv4, should be in order of preference) |
 | dns                  |list   |`<local address>`| DNS servers to announce, accepts IPv4 and IPv6 |
 | dnr                  |list   |disabled| Encrypted DNS servers to announce, `<priority> <domain name> [<comma separated IP addresses> <SvcParams (key=value)>...]` |
index cb971fd961e30e6ea30614ec0f54318c71089ac3..6948b0fb236b40ef46a66dd79f4bc536a8471878 100644 (file)
@@ -69,7 +69,7 @@ struct sys_conf sys_conf = {
 #define HOSTID_LEN_MAX 64
 #define HOSTID_LEN_DEFAULT HOSTID_LEN_MIN
 
-#define PD_MIN_LEN_MAX (64-2) // must delegate at least 2 bits of prefix
+#define PD_MIN_LEN_MAX 64
 
 #define OAF_DHCPV6     (OAF_DHCPV6_NA | OAF_DHCPV6_PD)
 
@@ -1456,12 +1456,14 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr
 
        if ((c = tb[IFACE_ATTR_DHCPV6_PD_MIN_LEN])) {
                uint32_t pd_min_len = blobmsg_get_u32(c);
-               if (pd_min_len > PD_MIN_LEN_MAX)
-                       iface->dhcpv6_pd_min_len = PD_MIN_LEN_MAX;
-               iface->dhcpv6_pd_min_len = pd_min_len;
-               if (pd_min_len > PD_MIN_LEN_MAX)
+
+               if (pd_min_len > PD_MIN_LEN_MAX) {
+                       pd_min_len = PD_MIN_LEN_MAX;
                        warn("Clamped invalid %s value configured for interface '%s' to %d",
-                            iface_attrs[IFACE_ATTR_DHCPV6_PD_MIN_LEN].name, iface->name, iface->dhcpv6_pd_min_len);
+                            iface_attrs[IFACE_ATTR_DHCPV6_PD_MIN_LEN].name, iface->name, pd_min_len);
+               }
+
+               iface->dhcpv6_pd_min_len = pd_min_len;
        }
 
        if ((c = tb[IFACE_ATTR_DHCPV6_NA]))